import request from '@/utils/request'

// 登录
export function login(loginform) {
  return request({
    url: '/api/ucenter/teacher/login',
    method: 'POST',
    data: loginform
  })
}

// 注册
export function register(registerform) {
  return request({
    url: '/api/ucenter/teacher/register',
    method: 'POST',
    data: registerform
  })
}

// 获取验证码
export function getCheckCode(email) {
  return request({
    url: `/api/mail/send/${email}`,
    method: 'GET'
  })
}
// 注销
export function exit(teacherId) {
  return request({
    url: `/admin/ucenter/teacher/exit/${teacherId}`,
    method: 'POST'
  })
}

// 根据工号查询教师拥有的菜单权限
export function getRightMenuListByTeacherId(teacherId) {
  return request({
    url: `/admin/ucenter/teacher/getRightMenuList/${teacherId}`,
    method: 'GET'
  })
}

// 根据工号查询教师拥有的权限
export function getRightListByTeacherId(teacherId) {
  return request({
    url: `/admin/ucenter/teacher/getRightList/${teacherId}`,
    method: 'GET'
  })
}

// 查询用户名
export function getUserName() {
  return request({
    url: '/admin/ucenter/teacher/getUserName',
    method: 'GET'
  })
}

// 获取所有教师信息
export function getTeacherList() {
  return request({
    url: '/admin/ucenter/teacher/getTeacherList',
    method: 'GET'
  })
}
// 分页查询教师信息
export function getTeacherListByPage(queryInfo) {
  return request({
    url: `/admin/ucenter/teacher/getTeacherList/${queryInfo.pagenum}/${queryInfo.pagesize}`,
    method: 'POST',
    data: {
      username: queryInfo.username,
      roleId: queryInfo.roleId
    }
  })
}

// 根据 id 查询教师信息
export function getTeacher(id) {
  return request({
    url: `/admin/ucenter/teacher/getTeacher/${id}`,
    method: 'GET'
  })
}

// 更新教师信息
export function updateTeacher(form) {
  return request({
    url: '/admin/ucenter/teacher/updateTeacher',
    method: 'POST',
    data: form
  })
}

// 禁用用户
export function disableTeacher(id) {
  return request({
    url: `/admin/ucenter/teacher/disableTeacher/${id}`,
    method: 'POST'
  })
}

// 解禁用户
export function enableTeacher(id) {
  return request({
    url: `/admin/ucenter/teacher/enableTeacher/${id}`,
    method: 'POST'
  })
}

// 删除教师
export function deleteTeacher(id) {
  return request({
    url: `/admin/ucenter/teacher/deleteTeacher/${id}`,
    method: 'DELETE'
  })
}

// 修改用户密码
export function updatePassword(id, password) {
  return request({
    url: `/admin/ucenter/teacher/updatePassword/${id}/${password}`,
    method: 'PUT'
  })
}

// 根据权限 id 判断当前教师是否拥有该权限
export function checkAuthByRightId(rightId) {
  return request({
    url: `/admin/ucenter/teacher/checkAuth/${rightId}`,
    method: 'GET'
  })
}
